package o;

import android.os.Handler;
import android.os.Looper;
import androidx.annotation.Nullable;
import java.util.ArrayList;
import java.util.Iterator;
import o.aim.a;
import o.aim.c;

public abstract class ahy implements aim {
    @Nullable
    private Object ˊ;
    @Nullable
    private abr ˋ;
    private final ArrayList<c> ˎ = new ArrayList(1);
    private final ail.c ˏ = new ail.c();
    @Nullable
    private Looper ॱ;

    protected abstract void ˎ();

    protected abstract void ॱ(@Nullable alx o_alx);

    protected final void ˏ(abr o_abr, @Nullable Object obj) {
        this.ˋ = o_abr;
        this.ˊ = obj;
        Iterator it = this.ˎ.iterator();
        while (it.hasNext()) {
            ((c) it.next()).ˏ(this, o_abr, obj);
        }
    }

    public final ail.c ˏ(@Nullable a aVar) {
        return this.ˏ.ˊ(0, aVar, 0);
    }

    protected final ail.c ˊ(int i, @Nullable a aVar, long j) {
        return this.ˏ.ˊ(i, aVar, j);
    }

    public final void ˏ(Handler handler, ail o_ail) {
        this.ˏ.ˏ(handler, o_ail);
    }

    public final void ˏ(ail o_ail) {
        this.ˏ.ॱ(o_ail);
    }

    public final void ॱ(c cVar, @Nullable alx o_alx) {
        Looper myLooper = Looper.myLooper();
        boolean z = this.ॱ == null || this.ॱ == myLooper;
        amm.ˊ(z);
        this.ˎ.add(cVar);
        if (this.ॱ == null) {
            this.ॱ = myLooper;
            ॱ(o_alx);
        } else if (this.ˋ != null) {
            cVar.ˏ(this, this.ˋ, this.ˊ);
        }
    }

    public final void ˎ(c cVar) {
        this.ˎ.remove(cVar);
        if (this.ˎ.isEmpty()) {
            this.ॱ = null;
            this.ˋ = null;
            this.ˊ = null;
            ˎ();
        }
    }
}
